import axios from 'axios'
import { getToken } from '@/utils/auth'



export function goBacks() {
  this.$router.go(-1)
}
export function Verify(content) {
  if (!content.replace(/(^\s*)|(\s*$)/g, '') == '') {
    return false
  }
  return true 
}
export  function uploadDocument(formData) {
  axios({
    url: process.env.VUE_APP_BASE_API + '/api/fd/document/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data;charset=utf-8',
      Authorization: getToken()
    }
  })
    .then((res) => {
      if (res.data.code === 1) {
        this.$message.success('上传成功')
        this.fileList = []
        this.$refs.upload.clearFiles()
        this.$parent.getList()
        this.$emit('uploadRes',res)
      }
      this.$message.error('上传失败')
    })
    .catch((err) => {
      console.log(err)
    })
}

export function arrDifferent(data) {
  for (var i = 0; i < data.length; i++) {
    for (var j = i + 1; j < data.length; j++) {
      if (data[i].id == data[j].id) {
        data.splice(j, 1)
        j--
      } 
    }     
  }
  return data
}


import Sortable from 'sortablejs'


//列拖拽
export function columnDrop(sortable,dropCol) {
  const wrapperTr = document.querySelector('.el-table__header-wrapper tr')
  sortable = Sortable.create(wrapperTr, {
    animation: 180,
    delay: 0,
    onEnd: (evt) => {
      const oldItem = dropCol[evt.oldIndex]
      dropCol.splice(evt.oldIndex, 1)
      dropCol.splice(evt.newIndex, 0, oldItem)
    }
  })
}




